#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QTcpSocket>
#include <QStandardItemModel>
#include <QModelIndex>
#include "dialog.h"

namespace Ui {
class MainWindow;
}

typedef struct user_message
{
    QString username;
    QString message;
}USER_MESSAGE;

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    explicit MainWindow(Dialog &dialog, QWidget *parent = 0);
    ~MainWindow();

    USER_DATA usr_data;
    char myname[20];
    int  onlineuser;
    QString *currentmessage;
    USER_MESSAGE user_message[100]; //保存用户消息记录
    QTcpSocket *socket;

private slots:
    void on_pushButton_clicked();
    void socket_Read_Data();
    void listWidget_clicked(QModelIndex index);

private:
    Ui::MainWindow *ui;
    QStandardItemModel *standardItemModel;//声明model
    void closeEvent(QCloseEvent *e);
    QString getmessage(QString &username);
};

#endif // MAINWINDOW_H 1 2 3 4 5 6 7
